package lib.Common;

import java.text.SimpleDateFormat;

public class Cast {
	/**
	 * Useful cast method's
	 */
	public static boolean StringToBoolean(String string) {
		boolean tmp = false;
		if (string.equals("true")) {
			tmp = true;			
		}else if (string.equals("false")) {
			tmp = false;
		}
		return tmp;
	}
	
	public static int StringToInt(String string) {
		int tmp = 2;
		
		if(string.equals("all")) {
			tmp = 0;
		}else if (string.equals("friends")) {
			tmp=1;
		}else if (string.equals("nobody")) {
			tmp = 2;
		}
		return tmp;
	}
	
	public static String IntToString(int i) {
		if (i==0) {
			return "all";
		}else if (i==1) {
			return "friends";
		}else {
			return "nobody";
		}
	}
	
	public static String BoolToString(boolean state) {
		if (state) {
			return "true";
		}else {
			return "false";
		}
	}
	
	public static String formatTimeStampAs_ddmmyyyy(long value){
		return new SimpleDateFormat("dd/MM/yyyy").format(value);
	}
}